<template>
  <div class="all">
  <div class="i-top">
        <div class="wrap">
          <router-link tag="a" :to="{path:'/indexPage'}" class="logo"></router-link>
          <div class="link-menu-list">
            <div class="is-student">
              当前学生身份
            </div>
            <!-- 小头像 -->
            <div class="minixFace">
              <img :src='imgurl' style="width: 22px;height: 22px"  v-if="img_url">
              <img :src='images.xxt' v-else>
<!--              <router-link tag="a" :to="{path:'/indexPage'}" @click="exit">&nbsp;&nbsp;&nbsp;注销</router-link>-->
              <span @click="exit" >&nbsp;&nbsp;<a href="javascript:;">{{user_name}}&nbsp;注销</a></span>
            </div>
          </div>
        </div>
      </div>
  <div class="daohang">
        <el-menu
        :default-active="activeIndex"
        class="el-menu-demo"
        mode="horizontal"
        background-color="#545c64"
        text-color="#fff"
        active-text-color="#ffd04b">
          <el-menu-item index="1"><a href="javascript:;" @click="home">首页</a></el-menu-item>
          <el-submenu index="2">
            <template slot="title">行业</template>
            <el-menu-item index="2-1">IT互联网</el-menu-item>
            <el-menu-item index="2-2">网络电商</el-menu-item>
            <el-menu-item index="2-3">工程实施</el-menu-item>
          </el-submenu>

          <el-submenu index="3">
            <template slot="title">职位</template>
            <el-menu-item index="3-1">搜索职位</el-menu-item>
            <el-menu-item index="3-2">我投递的职位</el-menu-item>
            <el-menu-item index="3-3">我收藏的职位</el-menu-item>
          </el-submenu>
          <el-menu-item index="4"><a href="javascript:;" @click="to_res">简历</a></el-menu-item>
          <el-menu-item index="5">海外</el-menu-item>
          <el-menu-item index="6">校园</el-menu-item>
          <el-submenu index="7">
            <template slot="title">简历优化</template>
            <el-menu-item index="7-1">简历置顶</el-menu-item>
            <el-menu-item index="7-2">面试辅导</el-menu-item>
            <el-menu-item index="7-3">职业咨询</el-menu-item>
            <el-menu-item index="7-4">简历代投</el-menu-item>
          </el-submenu>
          <el-menu-item index="8">下载App</el-menu-item>
        </el-menu>
      </div>
  </div>
</template>

<script>
    export default {
      name: "Index-top1",
      data() {
        return {
          activeIndex: '1',
          user_name: '',
          user_id:'',
          img_url: '',
          images: {
            xxt: require('../../assets/img/touxiang1.png'),
          }
        }
      },
      mounted: function () {
        this.house()
      },
      methods: {
        to_res() {
          this.$router.push({
            path: '/resumeDisplay'
          })
        },
        home() {
          this.$router.push({
            path: '/indexMainPage'
          })
        },
        house() {
          if (this.$session.get('userPhone')) {
            console.log(this.$session.get('userPhone'));
            this.$axios({
              method: 'GET',
              url: 'api/img_loading'
            }).then((result) => {
              console.log(result.data);
              this.user_name = result.data.user_name;
              this.user_id = result.data.user_id;
              if (result.data.avatar_url == '#'){
                this.img_url = false
              }else {
                this.img_url = true
              }
            })
          } else {
            alert('请先登陆！！');
            this.exit()
          }

        },
        exit() {
          this.$session.remove('userPhone');
          this.$axios({
            method: 'GET',
            url: 'api/exit_user',
          }).then((data) => {
            console.log(data.data.exit_case)
          });
          this.$router.push({
            path: '/indexPage'
          });
        },
      },
      computed:{
        imgurl: function () {
          return require('../../../../SPI_Django/media/'+String(this.user_id)+'/img/HeadPortrait.jpg')
        }
      },
    }
</script>


